package com.hp.idempotence.v4.repository;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.hp.idempotence.v4.model.User;

@Repository
public interface UserRepository extends  JpaRepository<User, Long> {

	@Transactional
	@Modifying
	@Query(value="update user set realname = ?1 ,version = version+1 where id = ?2 and version=?3 ",nativeQuery=true)
	int updateUser(String realname, Long id, Integer version);

}
